<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <title>添加信息</title>
  <div th:replace="common/link::header"></div>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">基本信息</div>
        <div class="layui-card-body">
            <div class="layui-row">
                <div class="layui-form layui-form-pane" lay-filter="ad_form" id="ad_form">
                    <input type="hidden" name="id" id="id">
                    <!--第一个-->
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">线路编号</label>
                        <div class="layui-input-inline">
                            <input type="text" lay-verify="required" class="layui-input" name="lineNo"
                                   placeholder="请输入线路编号"/>
                        </div>
                    </div>

                    <select id="lineNameS" name="lineNameS" lay-filter="lineNameTest"></select>
                    <select id="lineNameS2" name="lineNameS" lay-filter="lineNameTest2"></select>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">线路名称</label>
                        <div class="layui-input-inline">
                            <input type="text" lay-verify="required" class="layui-input" name="lineName"
                                   placeholder="请输入线路名称"/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">机器序列号</label>
                        <div class="layui-input-inline">
                            <input type="text" lay-verify="required" class="layui-input" name="sNumber"
                                   placeholder="请输入机器序列号,公共信息请输入common"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">门翼编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="GPartNumber"
                                   placeholder="请输入门翼编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">门翼名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="GPartName" placeholder="请输入门翼名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">读写器编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="RPartNumber"
                                   placeholder="请输入读写器编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">读写器名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="RPartName" placeholder="请输入读写器名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">磁模块编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="MPartNumber"
                                   placeholder="请输入磁模块编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">磁模块名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="MPartName" placeholder="请输入磁模块名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">显示屏编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="DPartNumber"
                                   placeholder="请输入显示屏编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">显示屏名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="DPartName" placeholder="请输入显示屏名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">通行控制单元编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="CPartNumber"
                                   placeholder="请输入通行控制单元编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">通行控制单元名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="CPartName" placeholder="请输入通行控制单元名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">备用电源编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="EPartNumber"
                                   placeholder="请输入备用电源编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">备用电源名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="EPartName" placeholder="请输入备用电源名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">数据存储卡编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="SPartNumber"
                                   placeholder="请输入数据存储卡编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">数据存储卡名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="SPartName" placeholder="请输入数据存储卡名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">编码器编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="CoPartNumber"
                                   placeholder="请输入编码器编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">编码器名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="CoPartName"
                                   placeholder="请输入编码器名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">工控机编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="IpcPartNumber"
                                   placeholder="请输入工控机编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">工控机名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="IpcPartName"
                                   placeholder="请输入工控机名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">二维码识读模块编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="QrPartNumber"
                                   placeholder="请输入二维码识读模块编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">二维码识读模块名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="QrPartName"
                                   placeholder="请输入二维码识读模块名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">人脸图像采集模块编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="FPartNumber"
                                   placeholder="请输入人脸图像采集模块编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">人脸图像采集模块名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="FPartName" placeholder="请输入人脸图像采集模块名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">旅行证件识读模块编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="TPartNumber"
                                   placeholder="请输入旅行证件识读模块编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">旅行证件识读模块名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="TPartName" placeholder="请输入旅行证件识读模块名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">电机驱动器编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="MdPartNumber"
                                   placeholder="请输入电机驱动器编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">电机驱动器名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="MdPartName"
                                   placeholder="请输入电机驱动器名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">测量光幕编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="MlPartNumber"
                                   placeholder="请输入测量光幕编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">测量光幕名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="MlPartName"
                                   placeholder="请输入测量光幕名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">安全光幕编码</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="SlPartNumber"
                                   placeholder="请输入安全光幕编码"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 180px">安全光幕名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="SlPartName"
                                   placeholder="请输入安全光幕名称"/>
                        </div>
                    </div>
                    <div class="layui-form-item layui-hide">
                        <input type="button" lay-submit lay-filter="save-submit" id="save-submit" value="确认">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:replace="common/script::footer"></div>
<script th:inline="javascript">
  layui.config({
      base: '/static/layuiadmin/' //静态资源所在路径
  }).extend({
     index: 'lib/index', //主入口模块
  }).use(['index', 'form','crud','upload'], function(){
    let $ = layui.$,
            form = layui.form,
            crud = layui.crud,
            upload = layui.upload;
    // 编辑器
    //crud.initEditor('adContent');
    form.on('submit(save-submit)', function(data) {
        $.ajax({
        type: 'POST',
        url:  ctx + '/app/user/add2',
        data: JSON.stringify(data.field),
        contentType:'application/json;charset=UTF-8',
        dataType: 'json',
        success: function(result) {
          layer.msg(result.message);
          if (result.code === 200) {
            let index = parent.layer.getFrameIndex(window.name);
            // 关闭
            parent.layer.close(index);
            // 刷新
            parent.location.reload();
          }
        }
      });
    });

      //获取第一个值
      $.ajax({
          url: ctx + '/app/Material/pageTest',
          type: 'get',
          dataType: 'json',
          success: function (data) {
              let str1 = "<option value='0'>请选择门翼编码</option>";
              for (let i of data) {
                  str1 += `<option name="lineName" value='${i.materialCode}'>${i.materialCode}</option>`;
              }
              $("#lineNameS").html(str1);
              form.render();
          }, error: function () {
              layer.msg('没有获取到数据');
          }
      });
      //下拉框1监听事件
      form.on('select(lineNameTest)', function (data) {
          if ($('#lineNameS option:checked').val() != 0) {
              $.ajax({
                  url: ctx + '/app/ad/pageTest2',
                  type: 'POST',
                  dataType: 'json',
                  data: JSON.stringify({
                      lineName: $('#lineNameS option:checked').text()
                  }),
                  contentType: 'application/json;charset=UTF-8',
                  success: function (data) {
                      console.log( $('#lineNameS option:checked').text());
                  }
                  });
          }
      });
  });
</script>
</body>
</html>